<?php
/**
 * Created by PhpStorm.
 * User: a4041
 * Date: 2018/6/13
 * Time: 13:46
 */

namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class CashConfig extends Model
{
    use SoftDeletes;
    protected $guarded = ['id'];
    protected $appends = ['bank_name'];       // 表里没有的字段


    //处理订单未处理金额
    public function getBankNameAttribute()
    {
        $role = $this->attributes['bank_type'];  // $this->attributes表的字段属性
        $bankname = '中国建设银行';
        switch ($role){
            case 1:
                $bankname = '中国工商银行';
                break;
            case 2:
                $bankname = '中国建设银行';
                break;
            case 3:
                $bankname = '中国农业银行';
                break;
            case 4:
                $bankname = '中国银行';
                break;
            case 5:
                $bankname = '邮政储蓄';
                break;
            case 0:
                $bankname = '中国建设银行';
                break;
            default:
//                $bankname = '服务员';
                break;
        }

        return $bankname;
    }
}